package portal.monitor.dao.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import portal.monitor.dao.MonitorHostGroup;
import portal.monitor.dao.mapper.MonitorHostGroupMapper;

import java.util.List;

@Service
public class MonitorHostGroupService {

    @Autowired
    MonitorHostGroupMapper monitorHostGroupMapper;

    public Integer insert(MonitorHostGroup monitorHostGroup){
        return monitorHostGroupMapper.insert(monitorHostGroup);
    }
    
    public MonitorHostGroup getNewsetRec(){
    	return monitorHostGroupMapper.getNewsetRec();
    }
    	

    public Integer deleteByPrimaryKey(int hostGroupId){
        return monitorHostGroupMapper.deleteByPrimaryKey(hostGroupId);
    }

    public Integer updateByPrimaryKey(MonitorHostGroup monitorHostGroup){
        return monitorHostGroupMapper.updateByPrimaryKey(monitorHostGroup);
    }

    public MonitorHostGroup selectByPrimaryKey(int hostGroupId){
        return monitorHostGroupMapper.selectByPrimaryKey(hostGroupId);
    }

    public List<MonitorHostGroup> selectAll(){
        return monitorHostGroupMapper.selectAll();
    }

    public List<MonitorHostGroup> selectByPage(int currentPage, int onePageCount){
        if(onePageCount<1||currentPage<1) return  null;
        int currentPosition = (currentPage-1)*onePageCount;
        return monitorHostGroupMapper.selectByPage(currentPosition, onePageCount);
    }

    public Integer pageNum(Integer onePageCount){
        if(onePageCount<1) return -1;
        int hostGroupNum = monitorHostGroupMapper.hostGroupNum();
        return (hostGroupNum%onePageCount==0)?(hostGroupNum/onePageCount):(hostGroupNum/onePageCount+1);
    }
    
   
}
